package com.siwei.mes.controller.experiment;

import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.entity.system.Equipment;
import com.siwei.mes.entity.vo.PrintExperimentVo;
import com.siwei.mes.entity.vo.PrintMixInfoVo;
import com.siwei.mes.entity.vo.PrintRwdInfoVo;
import com.siwei.mes.service.experiment.PrintService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.siwei.mes.common.exception.handler.MessageHandler.assertTrue;

/**
 * 打印试验委托
 *
 * @Description: 打印试验委托
 * @Version: 1.0
 * @author: mlchen
 * @date: 2024/7/24 10:34
 */
@Api(value = "打印试验委托")
@RestController
@RequestMapping("experimentPrint")
public class PrintController {
    @Resource
    private PrintService printService;

    @ApiOperation(value = "获取打印相关的数据-试验委托")
    @PostMapping("getExperimentPrintInfo")
    public Json getExperimentPrintInfo(@RequestBody PrintExperimentVo entity) {
        assertTrue(entity.getExperimentIdList() == null || entity.getExperimentIdList().isEmpty(), "试验台账id集合为空");
        return Json.succ().data(ApiResult.addList(printService.getExperimentPrintInfo(entity.getExperimentIdList())));
    }


    @ApiOperation(value = "获取打印相关的数据-ERP任务")
    @PostMapping("getErpRwdPrintInfo")
    public Json getErpRwdPrintInfo(@RequestBody PrintRwdInfoVo entity) {
        assertTrue(entity.getFrwdIdList() == null || entity.getFrwdIdList().isEmpty(), "ERP任务id集合为空");
        return Json.succ().data(ApiResult.addList(printService.getErpRwdPrintInfo(entity.getFrwdIdList())));
    }


    @ApiOperation(value = "获取打印相关的数据-ERP任务  根据任务单修改记录")
    @PostMapping("getErpRwdPrintInfoToUpdateLog")
    public Json getErpRwdPrintInfoToUpdateLog(@RequestBody PrintRwdInfoVo entity) {
        assertTrue(entity.getUpdateLogIdList() == null || entity.getUpdateLogIdList().isEmpty(), "任务单修改记录id集合为空");
        return Json.succ().data(ApiResult.addList(printService.getErpRwdPrintInfoToUpdateLog(entity.getUpdateLogIdList())));
    }

    @ApiOperation(value = "获取仪器设备相关打印数据")
    @PostMapping("getEquipmentPrintInfo")
    public Json getEquipmentPrintInfo(@RequestBody Equipment equipment) {
        return Json.succ().data(ApiResult.addList(printService.getEquipmentPrintInfo(equipment)));
    }

    @ApiOperation(value = "根据配合比查询打印的数据")
    @PostMapping("getPrintInfoByMixIds")
    public Json getPrintInfoByMixIds(@RequestBody PrintMixInfoVo printMixInfoVo) {
        return Json.succ().data(ApiResult.addList(printService.getPrintInfoByMixIds(printMixInfoVo.getMixIdList())));
    }
}
